﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObserverPattern
{
    /// <summary>
    /// 具體的觀察者
    /// </summary>
    public class ConcreteObserver : Observer
    {
        private string _name;
        private string _observerState;
        private ConcreteSubject _subject;

        public ConcreteObserver(ConcreteSubject subject, string name)
        {
            this._name = name;
            this._subject = subject;
        }

        public override string Update()
        {
            _observerState = _subject.SubjectState;
            return string.Format("Observer {0}'s new state is {1}", _name, _observerState);

        }

        public ConcreteSubject Subject
        {
            get { return _subject; }
            set { _subject = value; }
        }
    }
}
